<?php
include "../include/global.php";
include "../include/admin_check.php";
$xtpl = new XTemplate ("user.htm");
//
include "../include/function.php";
$xtpl->assign("left_panel", left_panel());
$xtpl->assign("header_panel", header_panel());
$xtpl->assign("footer_panel", footer_panel());

// define language
$xtpl->assign("lbl_user", User);
$xtpl->assign("lbl_no", No);
$xtpl->assign("lbl_username", UserName);
$xtpl->assign("lbl_firstname", FirstName);
$xtpl->assign("lbl_lastname", LastName);
$xtpl->assign("lbl_avatar", Avatar);
$xtpl->assign("lbl_edit", Edit);
$xtpl->assign("lbl_delete", Delete);
$xtpl->assign("lbl_addnew", Addnew);
$xtpl->assign("lbl_total", Total);
$xtpl->assign("lbl_row", Row);

$loginAdminID = $_SESSION['loginAdminID'];
//
$limit=15;$pagegroup_size=10;
if (!$page||$page==0){$page=1;}
$offset=($page-1)*$limit;
$xtpl->assign("page",$page);

$condition=" where 1=1 ";	
if($key){
   $condition.=" and username like '%$key%'";
}
$xtpl->assign("key",$key);

$stsql = "select id from ".pre_table."admin".$condition;
$rssql = execSQL($stsql);
$numrec=mysql_num_rows($rssql);
$OrderNo=1+$numrec-($page-1)*$limit;
$sql="select * from ".pre_table."admin".$condition." order by username asc limit $offset, $limit";
$rs = execSQL($sql);
while($row = mysql_fetch_array($rs)){
   
	$OrderNo=--$OrderNo;
	$row[OrderNo] = $OrderNo;
	
	if($row[image])
		$row[image]="<img src='../../media/user/$row[image]' width='60' height='40'>";
	else
		$row[image] = "NO IMAGE";
    $xtpl->insert_loop("MAIN.list",array("list"=>$row));	
}
$pages=pagenavigator($page,$numrec,$limit,$pagegroup_size,"m","user.php?key=$key");
$xtpl->assign("pages",$pages);
$xtpl->assign("numrec",$numrec);

////////////////////////////////////////
$xtpl->parse("MAIN");
eval("?".">".$xtpl->text("MAIN"));
?>